package cn.edu.java.stream.泛型;


class MyGenericClass<T extends Comparable<T>> {
    private T value;

    public MyGenericClass(T value) {
        this.value = value;
    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }

    public void printType() {
        System.out.println("Type: " + value.getClass().getName());
    }
}


public class ClassDemo {
    public static void main(String[] args) {
        // 创建一个Integer类型的对象
        MyGenericClass<Integer> intObj = new MyGenericClass<>(10);
        intObj.printType(); // 输出：Type: java.lang.Integer
        int value = intObj.getValue();
        System.out.println("Value: " + value); // 输出：Value: 10

        // 创建一个String类型的对象
        MyGenericClass<String> strObj = new MyGenericClass<>("Hello");
        strObj.printType(); // 输出：Type: java.lang.String
        String strValue = strObj.getValue();
        System.out.println("Value: " + strValue); // 输出：Value: Hello
    }
}
